package com.dtruth.dataflow.dbmanager;

import java.util.Properties;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;

import com.dtruth.dataflow.util.Env;

public class HBaseManager {

	private Configuration conf = null;
	private Object lock = new Object();

	private static HBaseManager hbaseManager = null;

	private HBaseManager() {

	}

	public static HBaseManager getInstance() {
		if (hbaseManager != null)
			return hbaseManager;
		else
			hbaseManager = new HBaseManager();
		return hbaseManager;
	}

	public Configuration getConf() {
		if (conf == null) {
			synchronized (lock) {
				if (conf == null) {
					Properties pro = Env.getInstance();
					conf = HBaseConfiguration.create();
					conf.set("hbase.zookeeper.property.clientPort", pro
							.getProperty("hbase.zookeeper.property.clientPort",
									"2181"));
					conf.set("hbase.zookeeper.quorum", pro.getProperty(
							"hbase.zookeeper.quorum", "localhost"));
					conf.set("hbase.master",
							pro.getProperty("hbase.master", "backee:60000"));
				}
			}
		}
		return conf;
	}
}
